netstat -i # interfaces
netstat -rn # routing table
traceroute 8.8.4.4 | head -2
netstat -tu | head -4 | tail -2 # tcp/udp
netstat -tu -a | grep -i listen | head -4 # all connections -> connected, listening, etc. default is stablished, time_wait
netstat -atu -e # extended
netstat -elt | head -4 # only listening
netstat -tn | grep :22
netstat -t | grep -i ssh
netstat -s # summery
netstat -plt | grep --color=no 'python' | head -2 | tail -2 # program
# my favorite is peanut, like peanut butter :)
sudo netstat -peanut
ss -tn | head -3
ss -ulna # connection less
ss -nt '( dport = :80 or dport = :443 )' src 192.168.1.0/24 dst 54.229.110.0/24
ss -lnu sport = :domain
ss -lp | grep python | head -1
ss -lup
nmap 192.168.0.1
nmap 192.168.0.0/30 # 192.168.0.* 192.168.0.0-80 --exclude 192.168.1.100
# nmap -iL /tmp/scanlist.txt --excludefile /tmp/exclude.txt
nmap -iL ./listToScan --excludefile ./excludeLst
nmap 192.168.0.1 -p 80
nmap 192.168.0.1 -p 80-800
nmap 192.168.0.1 -p 80,443,22,23,20-21 -sV | head | tail -6 # -sV determine service/version info
sudo nmap -O 192.168.0.1 # Os
nmap -p80 192.168.1.1
nmap --reason -F 192.168.1.1
nmap -sP 192.168.1.1,100,102 # do not scan ports :same as -sn --- only show which one are up /24 0-20
nmap -p80 192.168.1.1 -vvv
nmap --iflist | grep vbox.*1$ # interface and routes
nmap -sT -sU 127.0.0.1 -p T:8888,U:53 | grep open # sT, sU search tcp, udp
nmap --top-ports 5 192.168.1.1 | egrep 'open|close'
nmap -f 127.0.0.1 # use tiny fragmented IP packets
nmap --spoof-mac 0 127.0.0.1 | grep Spo
sudo nmap -n -D 127.0.0.1,127.0.0.2,127.0.0.3 192.x.x.1 --spoof-mac 0
nmap -PU # udp ping to bypass fw
The nc (or netcat) utility is used for just about anything under the sun involving TCP, UDP, or UNIX-domain sockets.
It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4 and IPv6.
nc -zv 192.168.1.1 53 80
nc -zv 192.168.1.1 53-80 2>&1 | grep -vi ref
nc towel.blinkenlights.nl 23 # star wars
# simple chat
nc -l 6030 # srv
nc 127.0.0.1 6033 # client
# send date
ss sport = 6033
cat slackware.iso | pv | nc -l 6033 # srv
nc 127.0.0.1 6033 > slackware.iso
nc -ul4 8080 # use udp instead of default tcp
ss -lu src 127.0.0.1 sport = http-alt # 8080
ncat -ltk 127.0.0.1 40601 # same as nc keep open (alive) nc has it too
nmap 127.0.0.1 -p 40601 | grep open
ss -tl sport = 40601
ncat -u -e /bin/bash -l 127.0.0.1 40401 -k --allow 127.0.0.1 -m 2
netstat -luan | grep 40401
sudo nmap -sU 127.0.0.1 -p 40401 --reason
Resources:
man netstat
man nmap
man ss
man netcat (nc is same)
man ncat
ipynb
format: https://github.com/ravexina/linux-notes. html
exports of project available at: https://ravexina.github.io/linux-notes.Linux Notes by Milad As (Ravexina) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.